<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       
      async function getData(){
         const p = await new Promise((resolve,reject)=>{
            console.log('开始请求数据a');
                try{
                    setTimeout(()=>{
                        console.log('数据a请求完毕');
                        const user = {
                            name:'xiaoA'
                        }
                        resolve('success')
                        reject('err')
                    })
                }catch(e){
                    reject(e.message)
                }
            })

            return 1
            
            //await的返回值就是promise实例成功的值
            console.log(p); 
        }
    // async返回一个成功状态的promise  值是return的值
    const A = getData()
    console.log(A);
    </script>
</body>
</html>